package com.hancher.plugins.hrasm9log;

import com.android.build.api.instrumentation.AsmClassVisitorFactory;
import com.android.build.api.instrumentation.ClassContext;
import com.android.build.api.instrumentation.ClassData;
import com.android.build.api.instrumentation.InstrumentationParameters;

import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;

public abstract class HrAsmLogVisitorFactory implements AsmClassVisitorFactory<InstrumentationParameters.None> {
    @Override
    public @NotNull ClassVisitor createClassVisitor(@NotNull ClassContext classContext, @NotNull ClassVisitor classVisitor) {
        return new HrAsmLogClassVisitor(Opcodes.ASM9, classVisitor);
//        return new HrAsmLogClassNode(Opcodes.ASM9, classVisitor);
    }

    @Override
    public boolean isInstrumentable(@NotNull ClassData classData) {
        return !classData.getClassName().contains("R$") && !classData.getClassName().endsWith("R") && !classData.getClassName().endsWith("Binding");
    }
}
